﻿using Helper;
using Helper.Models;
using System.Windows.Input;

namespace Starehe.ViewModels
{
    public class SchoolSetupVM: ViewModelBase
    {
        SchoolModel school;
        public SchoolSetupVM()
        {
            InitVars();
            CreateCommands();
        }

        protected override void InitVars()
        {
            Title = "SCHOOL SETUP";
            School = (Helper.Properties.Settings.Default.School != null) ? Helper.Properties.Settings.Default.School : new SchoolModel();
        }

        protected override void CreateCommands()
        {
            SaveCommand = new RelayCommand(o => 
            {
                Helper.Properties.Settings.Default.School = School;
                Helper.Properties.Settings.Default.Save();
                
            }, 
            o => true);
        }

        public SchoolModel School
        {
            get { return school; }
            private set
            {
                if (school != value)
                {
                    school = value;
                    NotifyPropertyChanged("School");
                }
            }
        }
        
        public ICommand SaveCommand
        {
            get;
            private set;
        }

        public override void Reset()
        {
        }
    }
}
